// ----------------------------------
// RSDK Project: Sonic 2
// Script Description: ST Screen Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// ========================
// Aliases
// ========================

private alias object.value0 : object.timer

// States
private alias 0 : STSCREEN_SETUP
private alias 1 : STSCREEN_FADEIN
private alias 2 : STSCREEN_SHOWSCREEN
private alias 3 : STSCREEN_FADEOUT


// ========================
// Events
// ========================

event ObjectUpdate
	switch object.state
	case STSCREEN_SETUP
		stage.activeLayer[0] = 1 // Show the "Sonic And Tails In" Screen layer
		object.timer = 320
		object.state++
		SetScreenFade(0x00, 0x00, 0x00, 0xFF)
		break
		
	case STSCREEN_FADEIN
		if object.timer > 0
			object.timer -= 16
		else
			object.state++
		end if
		SetScreenFade(0x00, 0x00, 0x00, object.timer)
		break
		
	case STSCREEN_SHOWSCREEN
		object.timer++
		if object.timer == 90
			object.timer = 0
			object.state++
		end if
		break
		
	case STSCREEN_FADEOUT
		if object.timer < 320
			object.timer += 12
		else
			ResetObjectEntity(object.entityPos, TypeName[ST Logo], 0, object.xpos, object.ypos)
		end if
		SetScreenFade(0x00, 0x00, 0x00, object.timer)
		break
		
	end switch
	
	temp0 = screen.xcenter
	FlipSign(temp0)
	temp0 += 256
	screen.xoffset = temp0
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
